package com.fs.leetcode.shuzu.sum;

import jdk.nashorn.internal.objects.annotations.Where;

/**
 * @author huyunqiang
 * @date 2020/5/17 13:31
 */
public class pingfang {

    /**
     * 一个数 c 是否存在 a,b 使 c^2 = a^2+b^2
     */

    public static boolean bo(int c){

        boolean flag = false;
        int b = (int) Math.sqrt(c);
        int a=0;
        int sum = a*a+b*b;
        while(b<c && a<c){
            if(sum == c){
                flag = true;
            }
            if(sum>c){
                b--;
            }else{
                a++;
            }
        }

        return flag;
    }

    public static void main(String[] args) {
        System.out.println(bo(5));
    }

}
